package com.unicloud.medical.oss.common.model.request;

import com.unicloud.medical.oss.common.model.FileMetaData;
import com.unicloud.medical.oss.common.util.CommonUtil;
import com.unisound.tracelog.common.config.jackson.TraceLogJsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class InnerUploadObjectRequest extends CommonRequest {

    /**
     * 桶名称
     */
    private String bucketName;

    /**
     * 对象名称
     */
    private String objectName;

    /**
     * 文件
     */
    @TraceLogJsonIgnore
    private FileMetaData file;

    public void setBucketName(String bucketName) {
        this.bucketName = StringUtils.trimToNull(bucketName);
    }

    public void setObjectName(String objectName) {
        this.objectName = CommonUtil.formatFolder(objectName);
    }

    @Override
    public String toString() {
        return "{"
                + "\"ossName\":\""
                + ossName + '\"'
                + ",\"bucketName\":\""
                + bucketName + '\"'
                + ",\"objectName\":\""
                + objectName + '\"'
                + ",\"file\":"
                + file.getFileName()
                + "}";
    }
}
